/**
 * Author: Dmitry Ustimov
 * Date: 5/31/13
 * Time: 8:14 PM
 */

package com.gmail.dmitryustimov.ms.java7.mediator.classic.work.demo.col2event1;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

public class Mediator implements Colleague {

    private String name;
    private List<Colleague> colleagueList = new ArrayList<>();
    private BigDecimal sum = BigDecimal.valueOf(0);

    public Mediator(String name) {
        this.name = name;
    }

    public void addColleague(AbstractColleague colleague) {
        colleagueList.add(colleague);
    }

    @Override
    public void process(Event event, Colleague colleague) {
        sum.add(BigDecimal.valueOf(1));
        for (Colleague c: colleagueList) {
            if (c != colleague) {
                c.process(event, colleague);
            }
        }
    }
}
